from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
# 连接浏览器
driver=webdriver.Edge()
# 窗口最大化
driver.maximize_window()
# 找到页面地址
driver.get('http://10.59.9.12:7001/')
time.sleep(3)
driver.find_element(By.CLASS_NAME,'search-input').send_keys('非洲之心')
time.sleep(3)
driver.find_element(By.CLASS_NAME,'search-input-btn').click()
time.sleep(3)
# 断言搜索结果
dy1=driver.find_element(By.XPATH,'/html/body/div[4]/a[2]').text
print(dy1)
time.sleep(3)
# 定位图片
driver.find_element(By.CLASS_NAME,'lazy').click()
time.sleep(3)
# 清空商品数量
driver.find_element(By.CLASS_NAME,'input-regula').clear()
time.sleep(3)
driver.find_element(By.CLASS_NAME,'input-regula').send_keys('2')
time.sleep(5)